﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="wfGoodsImagesManager.aspx.cs"
    Inherits="msBsc.WebUi.wfGoodsImagesManager" %>

<!DOCTYPE HTML>
<html>
<head id="Head1" runat="server"> 
    <title>图片管理</title> 
    <link rel="shortcut icon" href="/themes/Style1/Image/favicon.ico" type="image/x-icon" />
    <link href="/??themes/Style1/StyleQt.css,jqPlugin/kindeditor/themes/default/default.css" type="text/css" rel="stylesheet" />
    <script src='/??jqPlugin/js/jquery-1.8.3.min.js,js/jBase.js,js/jBPage.js,themes/Style1/jsQt.js,jqPlugin/kindeditor/kindeditor.js,jqPlugin/kindeditor/lang/zh_CN.js,jqPlugin/js/laytpl.js,jqPlugin/layer/layer.min.js,jqPlugin/layer/extend/layer.ext.js' type='text/javascript'></script>
    <script type="text/javascript"> 
        K = KindEditor;
        K.DEBUG = true;
        K.basePath = K.options.basePath = '/jqPlugin/kindeditor/';
        K.options.themesPath = K.options.basePath + 'themes/';
        K.options.langPath = K.options.basePath + 'lang/';
        K.options.pluginsPath = K.options.basePath + 'plugins/';
        function getfilequery() {
            return "&ParentId=" + $("#txtCurrDirId").val()
                                    + "&FileId=" + ""
                                    + "&RelId=" + ""
                                    + "&rType1=" + "1"
                                    + "&rType2=" + "0";
        };
        $(window).load(function () {
            var editor = K.editor({
                allowFileManager: true
            });
            $('#J_selectImage').click(function () {
                editor.uploadJson = '/pgajax.axd?F_UPLOAD=1&blSave=1&COOKATHID=' + (typeof (cookesc) == "undefined" ? "" : cookesc)
                                    + "&fType=" + "image"
                                    + getfilequery();
                editor.loadPlugin('multiimage', function () {
                    editor.plugin.multiImageDialog({
                        onClose: function () {
                            doToPageNm();
                        }
                        , clickFn: function (urlList) {
                            editor.hideDialog();
                        }
                    });
                });
            });
        });

        $(function () {
            $("#imglist .img-item").live("dblclick", function () {
                var $self = $(this);
                if ($self.hasClass("f-dir")) {
                    $("#txtCurrDirId").val($self.attr("file-id")); doToPageNm();
                } else {
                    showImgBig($self.find(" img").attr("src"));
                }
            });
            $("#imglist .img-item").live("click", function () {
                var $self = $(this);
                if (!$self.hasClass("f-dir")) {
                    $("#txtFileUrl").val($self.find(" img").attr("src"));
                    $("#txtFileUrl").selection(0, $("#txtFileUrl").val().length);
                }
            });
            $("#imglist input").live("click", function () {
                var $self = $(this).parent().parent();
                if ($self.hasClass("img-item-select")) {
                    $self.removeClass("img-item-select");
                    $(this).attr("checked", false);
                } else {
                    $self.addClass("img-item-select");
                    $(this).attr("checked", true);
                }
            }); 
        });

        function showImgBig(sImgUrl) {
            $.layer({
                type: 1,
                shade: [0],
                fix: true,
                title: '图片查看',
                maxmin: false,
                page: { html: '<img class="" src="' + sImgUrl + '" style=" max-width:auto;height:100%;"/>' },
                area: ['700px', '410px']
            });
             
        };

        function addNewDir() {
            layer.prompt({ title: '输入新文件夹的名字？' }, function (name) {
                jQuery.loadHtml('/pgajax.axd?F_UPLOAD=1&blSave=1'
                                    + "&IsDir=" + "1" + "&DirNme=" + name + getfilequery()).done(function () {
                                        layer.closeAll();
                                        doToPageNm();
                                    });
            });
        };

        function toUpDIr() {
            var _jsParam = new jsonRow();
            _jsParam.AddCell("ACTION", "toUpDIr");

            _jsParam.AddCell("CURR_DIR_ID", $("#txtCurrDirId").val());

            ajaxComm(_jsParam);
        };

        function deleteFile() {
            var _fileid = '';
            $("#imglist input[checked='checked']").each(function () {
                _fileid += _fileid == "" ? $(this).val() : "," + $(this).val();
            });
            if (_fileid) {
                var _jsParam = new jsonRow();
                _jsParam.AddCell("ACTION", "deleteFile");

                _jsParam.AddCell("FILE_IDS", _fileid);
                _jsParam.AddCell("CURR_DIR_ID", $("#txtCurrDirId").val());

                ajaxComm(_jsParam);
            }
        };

        function doToPageNm(_pNum) {
            var _jsParam = new jsonRow();
            GetFormJson("divCondition", _jsParam);
            _jsParam.AddCell("ACTION", "LoadFileList");
            _jsParam.AddCell("NEW_PAGE_NUM", _pNum || 1);
            _jsParam.AddCell("PAGE_ROW_COUNT", "28");
            _jsParam.AddCell("PAGE_ROW_SORT", "");

            _jsParam.AddCell("CURR_DIR_ID", $("#txtCurrDirId").val());

            ajaxComm(_jsParam);
        };

        function updateTableHtml(_data) {
            var tpl = HtmlUtil.htmlDecode(document.getElementById('sys_imglist_temp').innerHTML);
            laytpl(tpl).render(_data, function (render) {
                $("#imglist").html(render);
            });

            $("#Ratecurrpage").val(_data.page);
            createPaging('ratepaginator', _data.page, _data.total, function (_topagenum) { doToPageNm(_topagenum); });
        };
 
    </script> 
    <!--head fix rgn-->
    <style type="text/css">
        
        #fileQueue { width: 490px; margin: 5px; height: 230px; overflow: auto; border: 1px solid #E5E5E5; margin-bottom: 10px; }
    </style>
    <style type="text/css">
        html, body
        {
            background-color: White;
            margin-left: 0px;
            margin-top: 0px;
            margin-right: 0px;
            margin-bottom: 0px;
        }
        .img-item
        {
            float: left;
            background-color: #ddd;
            margin: 5px;
            padding: 5px;
            border: 2px solid #bbb;
        }
        .img-item-select
        {
            border: 2px solid #C00;
        }
        .text-overflow
        {
            width: 120px;
            display: block; /*内联对象需加*/
            width: 31em;
            word-break: keep-all; /* 不换行 */
            white-space: nowrap; /* 不换行 */
            text-overflow: ellipsis; /* 当对象内文本溢出时显示省略标记(...) ；需与overflow:hidden;一起使用。*/
            overflow: hidden; /* 内容超出宽度时隐藏超出部分的内容 */
        }
        .text-overflow2
        {
            width: 120px;
            white-space: nowrap;
            text-overflow: ellipsis;
            overflow: hidden;
        }
    </style> 
</head>
<body>
    <input type="hidden" id="Ratecurrpage" value="1">
    <div id="mallPage" class="tms-page mallAct tmall-  page-not-market">
        <!-- -->
        <!--商城通用顶通-->
        <%=new msBsc.WebUi.Code.QtHtmlGet().GetHeaderTopHtml()%>
        <%=new msBsc.WebUi.Code.QtHtmlGet().GetHeaderLogoDealerHtml("商户管理")%>
        <div id="content" class="content" style=" padding-top: 10px;">
            <div class="page lang-zh-S">
                <div id="mytaobao-panel" class="grid-c2">
                    <div class="col-main" id="J_Col_Main" style="padding-bottom: 0;">
                        <div class="main-wrap">
                            <div id="main-content">
                                <div id="fragment1"> 
                              
    <div style="margin: 5px;">
        <div id="divCondition" style="margin: 0px; border: solid 1px #C8D2E0;">
            <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td align="center">
                     <%--   <input type="button" onclick="javascript:doToPageNm();return false;" value="查询" id="btnFinder" />--%>
                        <input type="button" class="btn btn-mini btn-danger" onclick="javascript:addNewDir();return false;" value="新建文件夹"
                            id="Button1" />
                        <input type="button" class="btn btn-mini btn-danger" value="上传文件" id="J_selectImage" />
                        <input type="button" class="btn btn-mini btn-danger" onclick="javascript:if(confirm('确认要删除选中的文件吗？')){deleteFile();}return false;" value="删除选中的文件" />
                        <input type="button" class="btn btn-mini btn-danger" onclick="javascript:toUpDIr();return false;" value="返回上级" />
                    </td>
                    <td class="label" width="110px" style=" padding-left:15px;">
                        当前图片地址
                    </td>
                    <td align="right" width="110px">
                        <input id="txtFileUrl" style="width: 400px;" type="text" value="" />
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <div id="imglist" style="background-color: White; margin: 5px;">
    </div>
    <div style="clear:both;height:10px; line-height:10px;"></div>
    <div id="ratepaginator"></div>
                                </div>
                            </div>
                        </div>
                    </div> 
                    <!-- end col-main -->
                    <div class="col-sub" id="J_Col_Sub">
                        <%=new msBsc.WebUi.Code.QtHtmlGet().GetDealerMenu()%>
                    </div>
                    <div style="clear:both;"></div>
                </div>
                <!-- end mytaobao-panel -->
            </div>
        </div>
        <%=new msBsc.WebUi.Code.QtHtmlGet().GetFloorHtml()%>
    </div>
    
    <input id="txtCurrDirId" type="hidden" value="" />
    <!-- template -->
    <textarea id="sys_imglist_temp" style="display: none;">  
        {{# for(var i = 0, len = d.rows.length; i < len; i++){ }}
        <div class="img-item {{# if(d.rows[i].IS_DIR=='True'){ }} f-dir {{# }else{ }} f-file  {{#}}} " style="" file-id="{{ d.rows[i].FILE_ID }}">
            <div style=" background-color:White;">
            <div style=" height:100px; text-align:center;">
                <img class="" src="{{# if(d.rows[i].IS_DIR=='True'){ }}/jqPlugin/kindeditor/plugins/filemanager/images/folder-64.gif{{# }else{ }}{{ d.rows[i].FILE_V_PATH }} 120x100img{{#}}}" style=" max-width:120px;height:100px;"/>
            </div></div>
            <div  style=" display:inline-block;"  class="text-overflow2 text-overflow"> 
            <input id="ckb{{ d.rows[i].FILE_ID }}" type="checkbox" name="ckb{{ d.rows[i].FILE_ID }}" value="{{ d.rows[i].FILE_ID }}"/><label for="ckb{{ d.rows[i].FILE_ID }}"  title="{{ d.rows[i].FILE_NME }} "> {{ d.rows[i].FILE_NME }} </label>
              
            </div>
        </div>
        {{# } }} 
    </textarea>
    <!-- foot script -->
</body>
</html>
